﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Ppt = Microsoft.Office.Interop.PowerPoint;

namespace ObjectModel.PowerPoint
{
    /// <summary>
    /// A serializable class that caches a live reference to a PowerPoint shape object.
    /// </summary>
    public class CachedShape : ResolvableShape
    {
        Ppt.Shape mShape;

        public CachedShape() { } // Parameterless constructor needed for serialization.

        public CachedShape(Ppt.Shape shape)
        {
            StoredShape = new ResolvableShape(shape);
            mShape = shape;
        }

        public ResolvableShape StoredShape { get; set; }

        public override object Resolve()
        {
            if (mShape == null)
                mShape = StoredShape.Resolve() as Ppt.Shape;

            return mShape;
        }
    }
}
